package cn.itcast.com.Thread.ver2;


import java.util.Random;

public class Producer implements Runnable {

    private Container container;
    private Random random;
    private Food[] foodbill = {new Food("蟹黄包",3.5),new Food("肉包子",2),
           new Food ("豆沙包",1),new Food("生煎",5)};

    public Producer(Container container) {
        this.container = container;
        random = new Random();
    }

    @Override
    public void run() {
        while (true){
            try {
                container.setFood(foodbill[random.nextInt(foodbill.length)]);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
